import { createApp } from 'vue'
import App from './App.vue'
import justom, { utils } from 'justom-share'
import ElementPlus from 'element-plus'
import router from '@/router'
import store from '@/store'
import composition from './composition'
import httpInstance from '@/public/request'
import AppBackLink from '@/components/AppBackLink.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
// 映入下载的字体样式
import '@/assets/fonts/alibabaHunb.css'

// 代码高亮
import hljsVuePlugin from '@highlightjs/vue-plugin'

// collapse
import { ElCollapseTransition } from 'element-plus'
// import Print from "vue3-print-nb"

const app = createApp(App)

function useTable(app: App) {
  app.use(VXETable)
}

// $http
app.config.globalProperties.$http = httpInstance
app.config.globalProperties.$utils = utils
// this.set
app.config.globalProperties.set = function (arr: Array<any>, idx: any, value: any) {
    arr[idx] = value
}

app.component('AppBackLink', AppBackLink)

// plugins
app.use(router)
app.use(store)
app.use(ElementPlus, { size: 'small' })
app.use(justom)
app.use(useTable)
app.use(hljsVuePlugin)
//全局dialog属性设置
app._context.components.ElDialog.props.closeOnClickModal.default = false
app._context.components.ElDialog.props.closeOnPressEscape = false
//
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// 组件 组合/关联
composition({ app, router, store, httpInstance })
app.mount('#app')
